package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * ClassName: CustomerController
 * Package: com.atguigu.jxc.controller
 *
 * @Description:
 * @Author: xvyy
 * @Create: 2025/2/21 - 15:36
 * @Version: v1.0
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {


    @Autowired
    private CustomerService customerService;

    /**
     * 分页查询客户信息
     *
     * @param page       当前页码
     * @param rows       每页显示条数
     * @param customerName 客户名称
     * @return Map<String, Object> 客户信息列表
     */
    @PostMapping("/list")
    @RequiresPermissions(value = "客户管理")
    public Map<String, Object> list(Integer page, Integer rows, String customerName) {
        return customerService.list(page, rows, customerName);
    }

    /**
     * 保存客户信息
     *
     * @param customer
     * @return ServiceVO 客户信息保存结果
     */
    @PostMapping("/save")
    @RequiresPermissions(value = "客户管理")
    public ServiceVO save(Customer customer) {
        return customerService.save(customer);
    }

    /**
     * 删除客户信息
     *
     * @param customerIds 客户id集合
     * @return ServiceVO 客户信息删除结果
     */
    @RequiresPermissions(value = "供应商管理")
    @PostMapping("/delete")
    public ServiceVO delete(@RequestBody String customerIds) {
        return customerService.delete(customerIds);
    }


}
